#include<bits/stdc++.h>
using namespace std;
const int N=1e6+6;
int a[N];
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int t,n;
    cin>>t;
    while(t--){
        cin>>n;
        int c=0;
        int b[N]={0};
        for(int i=0;i<n;i++){
            cin>>a[i];
            b[a[i]]++;
            if(b[a[i]]>1){
                c+=a[i];
            }
        }
        cout<<c<<endl;
    }


return 0;
}
